import _ from 'lodash'
let workflowHost = 'https://app.uyiban.com'

const ENV = {
    development: 'dev',
    production: 'prod'
}
const CURRENT_ENV = ENV[process.env.NODE_ENV]

const common = {
    serviceHost: 'https://api.uyiban.com',
    cookieDomain: 'uyiban.com',
    loginUrl: 'https://u.uyiban.com/#/login',
    workflowFormDesign: `${workflowHost}/workflow/design/#/formdesign`,
    workflowProcessDesign: `${workflowHost}/workflow/design/#/processdesign`,
    wfApprove: `${workflowHost}/workflow/client/#/approve`
}
const ENV_CONFIG = {
    dev: app => {
        if (process.env.NODE_ENV === 'development') {
            workflowHost = 'http://192.168.0.157:81'
            const common = {
                serviceHost: 'http://192.168.0.24:8080',
                cookieDomain: '',
                loginUrl: '',
                workflowFormDesign: 'http://localhost:8299/#/formdesign',
                workflowProcessDesign: 'http://localhost:8299/#/processdesign',
                wfApprove: 'http://localhost:8599/#/approve'
            }
            const dev = {
                admin: {
                    loginUrl: '',
                    devLoginUrl: '/base/admin/login/passLogin',
                    loginParams: { mobile: 18059039677, password: 'Aa123456' }
                },
                ops: {
                    devLoginUrl: '/Ops/Passport/Users/login',
                    loginParams: { Mobile: 13800000000, Password: 'dddddd' }
                }
            }
            return _.assign(common, dev[app])
        }
    },
    prod: app => {
        const prod = {
            admin: {
                loginUrl: 'https://u.uyiban.com/#/login'
            },
            ops: {
                loginUrl: 'https://ops.uyiban.com/#/service'
            }
        }
        return prod[app]
    }
}

export default _.assign(common, ENV_CONFIG[CURRENT_ENV]('admin'))
